﻿using LanguageFeatures.Models;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace LanguageFeatures.Controllers
{
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            //string[] viewModel = new string[]
            //{
            //    "C#", "Language", "Features"
            //};

            //List<string> results = new List<string>();

            //foreach (Product p in Product.GetProducts()) {
            //    string name = p?.Name ?? "<No Name>";
            //    string category = p?.Category ?? "<None>";
            //    decimal? price = p?.Price ?? 0;
            //    string related = p?.Related?.Name ?? "<None>";
            //    bool inStock = p.InStock;

            //    results.Add($"Name:{name}, Category: {category}, Price: {price}, " +
            //        $"InStock: {inStock}, Related:{related}");
            //}

            Product[] productArray =
            {
                new Product {Name = "Kayak", Price = 275M},
                new Product {Name= "LifeJacket", Price = 48.95M},
                new Product {Name= "Soccer ball", Price = 19.50M},
                new Product {Name= "Corner flag", Price = 34.95M},
            };

            IProductSelection cart = new ShoppingCart(productArray);      

            return View("Index", cart.Products.Select(p=>p.Name));
        }
    }
}
